<?php
class company{
	function Insert($company)
	{
		$ci =& get_instance();
		
		$ci->load->library('user');
		$ci->user->Insert($company->user);
		
		$user = $ci->user->GetByEmail($company->user->email);
		
		$company->iduser = $user->id;
		
		unset($company->user);
		//var_dump($company);
		
		$ci->db->insert('company', $company);
	}
	
	function GetByEmail($email)
	{
		$ci =& get_instance();
		
		$ci->load->library('user');
		$user = $ci->user->GetByEmail($email);
		
		
		$query = $ci->db->get_where('company', array('iduser' => $user->id));
		$res = $query->result();
		
		$company = $res[0];
		$company->user = $user;
		unset($company->iduser);
		$company = array("company" => $company);
	
		return $company;
	}
	
}
?>